﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_LisaBroneering_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENLisaBroneeringQuery))]
    public class ENLisaBroneeringQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENLisaBroneeringQuery clazz;
        
        public ENLisaBroneeringQuerySerializer(IENLisaBroneeringQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.TehinguTyyp!=null) {
                Writer.WriteStartElement("tehingu_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TehinguTyyp))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("ehit_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.EhitId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("anes_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.AnesId))).ToString());
            Writer.WriteEndElement();
            if (clazz.BronKp!=null) {
                Writer.WriteStartElement("bron_kp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.BronKp))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("notar");
            if (clazz.Notar!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Notar))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Notar");
            }
            Writer.WriteEndElement();
            if (clazz.Tehinguobj!=null) {
                Writer.WriteStartElement("tehinguobj");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tehinguobj))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kommentaar!=null) {
                Writer.WriteStartElement("kommentaar");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kommentaar))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeostKp!=null) {
                Writer.WriteStartElement("teost_kp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TeostKp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TyhisKp!=null) {
                Writer.WriteStartElement("tyhis_kp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TyhisKp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KasutajaId!=null) {
                Writer.WriteStartElement("kasutaja_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.KasutajaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Probleemid!=null) {
                Writer.WriteStartElement("probleemid");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Probleemid))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Olek!=null) {
                Writer.WriteStartElement("olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MkmKommentaar!=null) {
                Writer.WriteStartElement("mkm_kommentaar");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MkmKommentaar))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "tehingu_tyyp")) {
                goto tehingu_tyyp;
            }
            else {
                if ((Reader.LocalName == "ehit_id")) {
                    goto ehit_id;
                }
                else {
                    if ((Reader.LocalName == "anes_id")) {
                        goto anes_id;
                    }
                    else {
                        if ((Reader.LocalName == "bron_kp")) {
                            goto bron_kp;
                        }
                        else {
                            if ((Reader.LocalName == "notar")) {
                                goto notar;
                            }
                            else {
                                if ((Reader.LocalName == "tehinguobj")) {
                                    goto tehinguobj;
                                }
                                else {
                                    if ((Reader.LocalName == "kommentaar")) {
                                        goto kommentaar;
                                    }
                                    else {
                                        if ((Reader.LocalName == "teost_kp")) {
                                            goto teost_kp;
                                        }
                                        else {
                                            if ((Reader.LocalName == "tyhis_kp")) {
                                                goto tyhis_kp;
                                            }
                                            else {
                                                if ((Reader.LocalName == "kasutaja_id")) {
                                                    goto kasutaja_id;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "probleemid")) {
                                                        goto probleemid;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "olek")) {
                                                            goto olek;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "mkm_kommentaar")) {
                                                                goto mkm_kommentaar;
                                                            }
                                                            else {
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        tehingu_tyyp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>tehingu_tyyp");
            }
            clazz.TehinguTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tehingu_tyyp")).Value;
            goto START;
        ehit_id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>ehit_id");
            }
            clazz.EhitId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ehit_id")).Value;
            goto START;
        anes_id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>anes_id");
            }
            clazz.AnesId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("anes_id")).Value;
            goto START;
        bron_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>bron_kp");
            }
            clazz.BronKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("bron_kp")).Value;
            goto START;
        notar:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>notar");
            }
            clazz.Notar = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notar")).Value;
            goto START;
        tehinguobj:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>tehinguobj");
            }
            clazz.Tehinguobj = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tehinguobj")).Value;
            goto START;
        kommentaar:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>kommentaar");
            }
            clazz.Kommentaar = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kommentaar")).Value;
            goto START;
        teost_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>teost_kp");
            }
            clazz.TeostKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teost_kp")).Value;
            goto START;
        tyhis_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>tyhis_kp");
            }
            clazz.TyhisKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tyhis_kp")).Value;
            goto START;
        kasutaja_id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>kasutaja_id");
            }
            clazz.KasutajaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("kasutaja_id")).Value;
            goto START;
        probleemid:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>probleemid");
            }
            clazz.Probleemid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("probleemid")).Value;
            goto START;
        olek:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>olek");
            }
            clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            goto START;
        mkm_kommentaar:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_LisaBroneering_query>mkm_kommentaar");
            }
            clazz.MkmKommentaar = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mkm_kommentaar")).Value;
            goto START;
        }
    }
}
